home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Blender 2.49b / blender-2.49b-windows.exe / $_4_ / .blender / scripts / bpymodules / defaultdoodads.py < prev    next >
Text File  |  2009-08-31  |  27KB  |  942 lines

  1. # Default Doodad Set for Discombobulator
  2. # by Evan J. Rosky, 2005
  3. # GPL- http://www.gnu.org/copyleft/gpl.html
  4. #
  5. # $Id: defaultdoodads.py 5497 2005-10-11 19:05:56Z ianwill $
  6. # --------------------------------------------------------------------------
  7. # ***** BEGIN GPL LICENSE BLOCK *****
  8. #
  9. # Copyright (C) 2005: Evan J. Rosky
  10. #
  11. # This program is free software; you can redistribute it and/or
  12. # modify it under the terms of the GNU General Public License
  13. # as published by the Free Software Foundation; either version 2
  14. # of the License, or (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
  19. # GNU General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU General Public License
  22. # along with this program; if not, write to the Free Software Foundation,
  23. # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  24. #
  25. # ***** END GPL LICENCE BLOCK *****
  26. # --------------------------------------------------------------------------
  27.  
  28.  
  29. #Run discombobulator.py, not this.
  30.  
  31. import Blender
  32. from Blender import NMesh,Object,Material
  33. from Blender.NMesh import Vert,Face
  34. from Blender.Mathutils import *
  35.         
  36. import BPyMathutils
  37. from BPyMathutils import genrand
  38. a = BPyMathutils.sgenrand(4859)
  39.  
  40. #Create random numbers
  41. def randnum(low,high):
  42.     num = genrand()
  43.     num = num*(high-low)
  44.     num = num+low
  45.     return num
  46.  
  47. face = Face()
  48. xmin = Vector([0,0,0])
  49. xmax = Vector([0,0,0])
  50. ymin = Vector([0,0,0])
  51. ymax = Vector([0,0,0])
  52. mxmin = Vector([0,0,0])
  53. mxmax = Vector([0,0,0])
  54. mymin = Vector([0,0,0])
  55. mymax = Vector([0,0,0])
  56. doodadCenter = Vector([0,0,0])
  57. orientation = 0
  58. center = Vector([0,0,0])
  59. tosel = 0
  60. seltopsonly = 0
  61. tempx = []
  62. doodadMesh = NMesh.GetRaw()
  63.  
  64. global materialArray
  65. global reassignMats
  66. global thereAreMats
  67. global currmat
  68. global doodSideMat
  69. global doodTopMat
  70.  
  71. #face is the face to add the doodad to.
  72. #sizeX and sizeY are values from 0.0 to 1.0 that represents a percentage the face that is covered by the doodad.
  73. #height is how tall the doodad is.
  74.  
  75. def settings(seltops,matArr,reasMats,therMats,sidemat,topmat):
  76.     global seltopsonly
  77.     global materialArray
  78.     global reassignMats
  79.     global thereAreMats
  80.     global currmat
  81.     global doodSideMat
  82.     global doodTopMat
  83.     materialArray = matArr
  84.     reassignMats = reasMats
  85.     thereAreMats = therMats
  86.     seltopsonly = seltops
  87.     doodSideMat = sidemat
  88.     doodTopMat = topmat
  89.  
  90. def setCurrMat(curma):
  91.     global currmat
  92.     currmat = curma
  93.  
  94. #Find center and orientation of doodad
  95. def findDoodadCenter(sizeX, sizeY):
  96.     #globalizing junk
  97.     global face
  98.     global xmin
  99.     global xmax
  100.     global ymin
  101.     global ymax
  102.     global orientation
  103.     global doodadCenter
  104.     global center
  105.     global tosel
  106.     global mxmin
  107.     global mxmax
  108.     global mymin
  109.     global mymax
  110.     global tempx
  111.     global seltopsonly
  112.     
  113.     #Find the center of the face
  114.     center = Vector([0,0,0])
  115.     for pt in face.v:
  116.         center = center + pt.co
  117.     center = divideVectorByInt(center,len(face.v))
  118.     
  119.     #Find Temp Location Range by looking at the sizes
  120.     txmin = ((divideVectorByInt((face.v[0].co + face.v[3].co),2)) - center)*(1-sizeX) + center
  121.     txmax = ((divideVectorByInt((face.v[1].co + face.v[2].co),2)) - center)*(1-sizeX) + center
  122.     tymin = ((divideVectorByInt((face.v[0].co + face.v[1].co),2)) - center)*(1-sizeY) + center
  123.     tymax = ((divideVectorByInt((face.v[2].co + face.v[3].co),2)) - center)*(1-sizeY) + center
  124.     
  125.     #Find Center of doodad
  126.     amtx = randnum(0.0,1.0)
  127.     amty = randnum(0.0,1.0)
  128.     thepoint = (((((txmin - txmax)*amtx + txmax) - ((tymin - tymax)*amty + tymax))*.5 + ((tymin - tymax)*amty + tymax)) - center)*2 + center
  129.     doodadCenter = Vector([thepoint[0],thepoint[1],thepoint[2]])
  130.     
  131.     #Find Main Range by looking at the sizes
  132.     mxmin = divideVectorByInt((face.v[0].co + face.v[3].co),2)
  133.     mxmax = divideVectorByInt((face.v[1].co + face.v[2].co),2)
  134.     mymin = divideVectorByInt((face.v[0].co + face.v[1].co),2)
  135.     mymax = divideVectorByInt((face.v[2].co + face.v[3].co),2)
  136.     
  137.     #Find x/y equivs for whole face
  138.     ve1 = (txmin - txmax)*amtx + txmax
  139.     ve1 = ve1 - mxmax
  140.     nax = ve1.length
  141.     ve1 = (mxmin - mxmax)
  142.     nax = nax/ve1.length
  143.     
  144.     ve1 = (tymin - tymax)*amty + tymax
  145.     ve1 = ve1 - mymax
  146.     nay = ve1.length
  147.     ve1 = (mymin - mymax)
  148.     nay = nay/ve1.length
  149.     
  150.     #Find new box thing
  151.     tempx = []
  152.     amtx = nax-sizeX/2
  153.     amty = nay-sizeY/2
  154.     tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center)
  155.     
  156.     amtx = nax-sizeX/2
  157.     amty = nay+sizeY/2
  158.     tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center)
  159.     
  160.     amtx = nax+sizeX/2
  161.     amty = nay+sizeY/2
  162.     tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center)
  163.     
  164.     amtx = nax+sizeX/2
  165.     amty = nay-sizeY/2
  166.     tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center)
  167.     
  168.     #Find New Location Range by looking at the sizes
  169.     xmin = divideVectorByInt((tempx[0] + tempx[3]),2)
  170.     xmax = divideVectorByInt((tempx[1] + tempx[2]),2)
  171.     ymin = divideVectorByInt((tempx[0] + tempx[1]),2)
  172.     ymax = divideVectorByInt((tempx[2] + tempx[3]),2)
  173.  
  174. #Make a point
  175. def makePoint(x,y,z=0):
  176.     global xmin
  177.     global xmax
  178.     global ymin
  179.     global ymax
  180.     global doodadCenter
  181.     global tosel
  182.     global seltopsonly
  183.     global face
  184.  
  185.     amtx = x
  186.     amty = y
  187.     thepoint = (((((xmin - xmax)*amtx + xmax) - ((ymin - ymax)*amty + ymax))*.5 + ((ymin - ymax)*amty + ymax)) - doodadCenter)*2 + doodadCenter
  188.     thepoint = thepoint + z*Vector(face.no)
  189.     tver = Vert(thepoint[0],thepoint[1],thepoint[2])
  190.     if tosel == 1 and seltopsonly == 0 and z == 0:
  191.         tver.sel = 1
  192.     return tver
  193.  
  194. #extrude ground-plane(s)
  195. def extrudedoodad(vArray,heig):
  196.     global face
  197.     global doodadMesh
  198.     global tosel
  199.     
  200.     topVArray = []
  201.     
  202.     doodadMesh.verts.extend(vArray)
  203.     
  204.     #Create array for extruded verts
  205.     for ind in range(0,(len(vArray))):
  206.         point = vArray[ind].co + heig*Vector(face.no)
  207.         ver = Vert(point[0],point[1],point[2])
  208.         if tosel == 1:
  209.             ver.sel = 1
  210.         topVArray.append(ver)
  211.         doodadMesh.verts.append(topVArray[ind])
  212.     
  213.     #make faces around sides
  214.     for ind in range(0,(len(vArray) - 1)):
  215.         face = Face()
  216.         face.v.extend([vArray[ind],vArray[ind+1],topVArray[ind+1],topVArray[ind]])
  217.         if tosel == 1 and seltopsonly == 0: face.sel = 1
  218.         if thereAreMats == 1:
  219.             if reassignMats == 0 or doodSideMat == 0:
  220.                 face.materialIndex = currmat
  221.             else:
  222.                 face.materialIndex = doodSideMat-1
  223.         doodadMesh.faces.append(face)
  224.     face = Face()
  225.     face.v.extend([vArray[len(vArray) - 1],vArray[0],topVArray[0],topVArray[len(topVArray) - 1]])
  226.     if tosel == 1 and seltopsonly == 0: 
  227.         face.sel = 1
  228.     if thereAreMats == 1:
  229.         if reassignMats == 0 or doodSideMat == 0:
  230.             face.materialIndex = currmat
  231.         else:
  232.             face.materialIndex = doodSideMat-1
  233.     doodadMesh.faces.append(face)
  234.     
  235.     return topVArray
  236.  
  237. #For switching face vertices
  238. def fixvertindex(ind):
  239.     if ind > 3:
  240.         indx = ind - 4
  241.     else:
  242.         indx = ind
  243.     return indx
  244.  
  245. #runs doodads
  246. def createDoodad(indexArray,facec,minsi,maxsi,minhei,maxhei,selec,amtmin,amtmax,facpercent):
  247.     global doodadMesh
  248.     global seltopsonly
  249.     global tosel
  250.     
  251.     doodadMesh = NMesh.GetRaw()
  252.     
  253.     theamt = round(randnum(amtmin,amtmax),0)
  254.     theamt = int(theamt)
  255.     tosel = selec
  256.     
  257.     for i in range(0,(theamt)):
  258.         if randnum(0,1) <= facpercent:
  259.             index = round(randnum(1,len(indexArray)),0)
  260.             index = indexArray[(int(index) - 1)]
  261.             
  262.             Xsi = randnum(minsi,maxsi)
  263.             Ysi = randnum(minsi,maxsi)
  264.             hei = randnum(minhei,maxhei)
  265.                     
  266.             #Determine orientation
  267.             orient = int(round(randnum(0.0,3.0)))
  268.             
  269.             #face to use as range
  270.             facer = Face()
  271.             facer.v.extend([facec.v[orient],facec.v[fixvertindex(1+orient)],facec.v[fixvertindex(2+orient)],facec.v[fixvertindex(3+orient)]])
  272.             
  273.             if index == 1:
  274.                 singleBox(facer,Xsi,Ysi,hei)
  275.             if index == 2:
  276.                 doubleBox(facer,Xsi,Ysi,hei)
  277.             if index == 3:
  278.                 tripleBox(facer,Xsi,Ysi,hei)
  279.             if index == 4:
  280.                 LShape(facer,Xsi,Ysi,hei)
  281.             if index == 5:
  282.                 TShape(facer,Xsi,Ysi,hei)
  283.             if index == 6:
  284.                 if randnum(0.0,1.0) > .5:
  285.                     SShape(facer,Xsi,Ysi,hei)
  286.                 else:
  287.                     ZShape(facer,Xsi,Ysi,hei)
  288.     
  289.     return doodadMesh
  290.  
  291. def divideVectorByInt(thevect,theint):
  292.     thevect.x = thevect.x/theint
  293.     thevect.y = thevect.y/theint
  294.     thevect.z = thevect.z/theint
  295.     return thevect
  296.  
  297. #Single Box Doodad
  298. def singleBox(facel, Xsize, Ysize, height):
  299.     #globaling junk
  300.     global face
  301.     global tosel
  302.     global doodadMesh
  303.     
  304.     face = Face()
  305.     face = facel
  306.     
  307.     findDoodadCenter(Xsize, Ysize)
  308.     
  309.     vertArray = []
  310.     
  311.     #place four points
  312.     vertArray.append(makePoint(0,0))
  313.     vertArray.append(makePoint(0,1))
  314.     vertArray.append(makePoint(1,1))
  315.     vertArray.append(makePoint(1,0))
  316.     topVertArray = extrudedoodad(vertArray,height)
  317.     
  318.     face = Face()
  319.     face.v.extend(vertArray)
  320.     face.v.reverse()
  321.     doodadMesh.faces.append(face)
  322.     face = Face()
  323.     face.v.extend(topVertArray)
  324.     if tosel == 1: 
  325.             face.sel = 1
  326.     if thereAreMats == 1:
  327.         if reassignMats == 0 or doodTopMat == 0:
  328.             face.materialIndex = currmat
  329.         else:
  330.             face.materialIndex = doodTopMat-1
  331.     doodadMesh.faces.append(face)
  332.     
  333. #Double Box Doodad
  334. def doubleBox(facel, Xsize, Ysize, height):
  335.     #globaling junk
  336.     global face
  337.     global tosel
  338.     global doodadMesh
  339.     
  340.     face = Face()
  341.     face = facel
  342.     
  343.     findDoodadCenter(Xsize, Ysize)
  344.     
  345.     vertArray = []
  346.     
  347.     #place first box
  348.     vertArray.append(makePoint(0,0))
  349.     vertArray.append(makePoint(0,1))
  350.     vertArray.append(makePoint(0.45,1))
  351.     vertArray.append(makePoint(0.45,0))
  352.     topVertArray = extrudedoodad(vertArray,height)
  353.     
  354.     face = Face()
  355.     face.v.extend(vertArray)
  356.     face.v.reverse()
  357.     doodadMesh.faces.append(face)
  358.     face = Face()
  359.     face.v.extend(topVertArray)
  360.     if tosel == 1: 
  361.             face.sel = 1
  362.     if thereAreMats == 1:
  363.         if reassignMats == 0 or doodTopMat == 0:
  364.             face.materialIndex = currmat
  365.         else:
  366.             face.materialIndex = doodTopMat-1
  367.     doodadMesh.faces.append(face)
  368.     
  369.     vertArray = []
  370.     
  371.     #place second box
  372.     vertArray.append(makePoint(0.55,0))
  373.     vertArray.append(makePoint(0.55,1))
  374.     vertArray.append(makePoint(1,1))
  375.     vertArray.append(makePoint(1,0))
  376.     topVertArray = extrudedoodad(vertArray,height)
  377.     
  378.     face = Face()
  379.     face.v.extend(vertArray)
  380.     face.v.reverse()
  381.     doodadMesh.faces.append(face)
  382.     face = Face()
  383.     face.v.extend(topVertArray)
  384.     if tosel == 1: 
  385.             face.sel = 1
  386.     if thereAreMats == 1:
  387.         if reassignMats == 0 or doodTopMat == 0:
  388.             face.materialIndex = currmat
  389.         else:
  390.             face.materialIndex = doodTopMat-1
  391.     doodadMesh.faces.append(face)
  392.  
  393. #Triple Box Doodad
  394. def tripleBox(facel, Xsize, Ysize, height):
  395.     #globaling junk
  396.     global face
  397.     global tosel
  398.     global doodadMesh
  399.     
  400.     face = Face()
  401.     face = facel
  402.     
  403.     findDoodadCenter(Xsize, Ysize)
  404.     
  405.     vertArray = []
  406.     
  407.     #place first box
  408.     vertArray.append(makePoint(0,0))
  409.     vertArray.append(makePoint(0,1))
  410.     vertArray.append(makePoint(0.3,1))
  411.     vertArray.append(makePoint(0.3,0))
  412.     topVertArray = extrudedoodad(vertArray,height)
  413.     
  414.     face = Face()
  415.     face.v.extend(vertArray)
  416.     face.v.reverse()
  417.     doodadMesh.faces.append(face)
  418.     face = Face()
  419.     face.v.extend(topVertArray)
  420.     if tosel == 1: 
  421.             face.sel = 1
  422.     if thereAreMats == 1:
  423.         if reassignMats == 0 or doodTopMat == 0:
  424.             face.materialIndex = currmat
  425.         else:
  426.             face.materialIndex = doodTopMat-1
  427.     doodadMesh.faces.append(face)
  428.     
  429.     vertArray = []
  430.     
  431.     #place second box
  432.     vertArray.append(makePoint(0.35,0))
  433.     vertArray.append(makePoint(0.35,1))
  434.     vertArray.append(makePoint(0.65,1))
  435.     vertArray.append(makePoint(0.65,0))
  436.     topVertArray = extrudedoodad(vertArray,height)
  437.     
  438.     face = Face()
  439.     face.v.extend(vertArray)
  440.     face.v.reverse()
  441.     doodadMesh.faces.append(face)
  442.     face = Face()
  443.     face.v.extend(topVertArray)
  444.     if tosel == 1: 
  445.             face.sel = 1
  446.     if thereAreMats == 1:
  447.         if reassignMats == 0 or doodTopMat == 0:
  448.             face.materialIndex = currmat
  449.         else:
  450.             face.materialIndex = doodTopMat-1
  451.     doodadMesh.faces.append(face)
  452.     
  453.     vertArray = []
  454.     
  455.     #place third box
  456.     vertArray.append(makePoint(0.7,0))
  457.     vertArray.append(makePoint(0.7,1))
  458.     vertArray.append(makePoint(1,1))
  459.     vertArray.append(makePoint(1,0))
  460.     topVertArray = extrudedoodad(vertArray,height)
  461.     
  462.     face = Face()
  463.     face.v.extend(vertArray)
  464.     face.v.reverse()
  465.     doodadMesh.faces.append(face)
  466.     face = Face()
  467.     face.v.extend(topVertArray)
  468.     if tosel == 1: 
  469.             face.sel = 1
  470.     if thereAreMats == 1:
  471.         if reassignMats == 0 or doodTopMat == 0:
  472.             face.materialIndex = currmat
  473.         else:
  474.             face.materialIndex = doodTopMat-1
  475.     doodadMesh.faces.append(face)
  476.  
  477. #The "L" Shape
  478. def LShape(facel, Xsize, Ysize, height):
  479.     #globaling junk
  480.     global face
  481.     global tosel
  482.     global doodadMesh
  483.     
  484.     face = Face()
  485.     face = facel
  486.     
  487.     findDoodadCenter(Xsize, Ysize)
  488.     
  489.     rcon1 = randnum(0.2,0.8)
  490.     rcon2 = randnum(0.2,0.8)
  491.     
  492.     vertArray = []
  493.     
  494.     #place L shape
  495.     vertArray.append(makePoint(0,0))
  496.     vertArray.append(makePoint(0,rcon1))
  497.     vertArray.append(makePoint(0,1))
  498.     vertArray.append(makePoint(rcon2,1))
  499.     vertArray.append(makePoint(rcon2,rcon1))
  500.     vertArray.append(makePoint(1,rcon1))
  501.     vertArray.append(makePoint(1,0))
  502.     vertArray.append(makePoint(rcon2,0))
  503.     topVertArray = extrudedoodad(vertArray,height)
  504.     
  505.     #This fills in the bottom of doodad with faceness
  506.     face = Face()
  507.     face.v.extend([vertArray[0],vertArray[1],vertArray[4],vertArray[7]])
  508.     face.v.reverse()
  509.     if thereAreMats == 1:
  510.         if reassignMats == 0 or doodTopMat == 0:
  511.             face.materialIndex = currmat
  512.         else:
  513.             face.materialIndex = doodTopMat-1
  514.     doodadMesh.faces.append(face)
  515.     face = Face()
  516.     face.v.extend([vertArray[1],vertArray[2],vertArray[3],vertArray[4]])
  517.     face.v.reverse()
  518.     if thereAreMats == 1:
  519.         if reassignMats == 0 or doodTopMat == 0:
  520.             face.materialIndex = currmat
  521.         else:
  522.             face.materialIndex = doodTopMat-1
  523.     doodadMesh.faces.append(face)
  524.     face = Face()
  525.     face.v.extend([vertArray[4],vertArray[5],vertArray[6],vertArray[7]])
  526.     face.v.reverse()
  527.     if thereAreMats == 1:
  528.         if reassignMats == 0 or doodTopMat == 0:
  529.             face.materialIndex = currmat
  530.         else:
  531.             face.materialIndex = doodTopMat-1
  532.     doodadMesh.faces.append(face)
  533.     
  534.     #This fills in the top with faceness
  535.     face = Face()
  536.     face.v.extend([topVertArray[0],topVertArray[1],topVertArray[4],topVertArray[7]])
  537.     if tosel == 1: 
  538.             face.sel = 1
  539.     if thereAreMats == 1:
  540.         if reassignMats == 0 or doodTopMat == 0:
  541.             face.materialIndex = currmat
  542.         else:
  543.             face.materialIndex = doodTopMat-1
  544.     doodadMesh.faces.append(face)
  545.     face = Face()
  546.     face.v.extend([topVertArray[1],topVertArray[2],topVertArray[3],topVertArray[4]])
  547.     if tosel == 1: 
  548.             face.sel = 1
  549.     if thereAreMats == 1:
  550.         if reassignMats == 0 or doodTopMat == 0:
  551.             face.materialIndex = currmat
  552.         else:
  553.             face.materialIndex = doodTopMat-1
  554.     doodadMesh.faces.append(face)
  555.     face = Face()
  556.     face.v.extend([topVertArray[4],topVertArray[5],topVertArray[6],topVertArray[7]])
  557.     if tosel == 1: 
  558.             face.sel = 1
  559.     if thereAreMats == 1:
  560.         if reassignMats == 0 or doodTopMat == 0:
  561.             face.materialIndex = currmat
  562.         else:
  563.             face.materialIndex = doodTopMat-1
  564.     doodadMesh.faces.append(face)
  565.     
  566. #The "T" Shape
  567. def TShape(facel, Xsize, Ysize, height):
  568.     #globaling junk
  569.     global face
  570.     global tosel
  571.     global doodadMesh
  572.     
  573.     face = Face()
  574.     face = facel
  575.     
  576.     findDoodadCenter(Xsize, Ysize)
  577.     
  578.     rcony = randnum(0.25,0.75)
  579.     rconx1 = randnum(0.1,0.49)
  580.     rconx2 = randnum(0.51,0.9)
  581.     
  582.     vertArray = []
  583.     
  584.     #place T shape
  585.     vertArray.append(makePoint(0,0))
  586.     vertArray.append(makePoint(0,rcony))
  587.     vertArray.append(makePoint(rconx1,rcony))
  588.     vertArray.append(makePoint(rconx1,1))
  589.     vertArray.append(makePoint(rconx2,1))
  590.     vertArray.append(makePoint(rconx2,rcony))
  591.     vertArray.append(makePoint(1,rcony))
  592.     vertArray.append(makePoint(1,0))
  593.     vertArray.append(makePoint(rconx2,0))
  594.     vertArray.append(makePoint(rconx1,0))
  595.     topVertArray = extrudedoodad(vertArray,height)
  596.     
  597.     #fills bottom with faceness
  598.     face = Face()
  599.     face.v.extend([vertArray[0],vertArray[1],vertArray[2],vertArray[9]])
  600.     face.v.reverse()
  601.     if thereAreMats == 1:
  602.         if reassignMats == 0 or doodTopMat == 0:
  603.             face.materialIndex = currmat
  604.         else:
  605.             face.materialIndex = doodTopMat-1
  606.     doodadMesh.faces.append(face)
  607.     face = Face()
  608.     face.v.extend([vertArray[2],vertArray[3],vertArray[4],vertArray[5]])
  609.     face.v.reverse()
  610.     if thereAreMats == 1:
  611.         if reassignMats == 0 or doodTopMat == 0:
  612.             face.materialIndex = currmat
  613.         else:
  614.             face.materialIndex = doodTopMat-1
  615.     doodadMesh.faces.append(face)
  616.     face = Face()
  617.     face.v.extend([vertArray[5],vertArray[6],vertArray[7],vertArray[8]])
  618.     face.v.reverse()
  619.     if thereAreMats == 1:
  620.         if reassignMats == 0 or doodTopMat == 0:
  621.             face.materialIndex = currmat
  622.         else:
  623.             face.materialIndex = doodTopMat-1
  624.     doodadMesh.faces.append(face)
  625.     face = Face()
  626.     face.v.extend([vertArray[8],vertArray[9],vertArray[2],vertArray[5]])
  627.     face.v.reverse()
  628.     if thereAreMats == 1:
  629.         if reassignMats == 0 or doodTopMat == 0:
  630.             face.materialIndex = currmat
  631.         else:
  632.             face.materialIndex = doodTopMat-1
  633.     doodadMesh.faces.append(face)
  634.     
  635.     #fills top with faceness
  636.     face = Face()
  637.     face.v.extend([topVertArray[0],topVertArray[1],topVertArray[2],topVertArray[9]])
  638.     if tosel == 1: 
  639.             face.sel = 1
  640.     if thereAreMats == 1:
  641.         if reassignMats == 0 or doodTopMat == 0:
  642.             face.materialIndex = currmat
  643.         else:
  644.             face.materialIndex = doodTopMat-1
  645.     doodadMesh.faces.append(face)
  646.     face = Face()
  647.     face.v.extend([topVertArray[2],topVertArray[3],topVertArray[4],topVertArray[5]])
  648.     if tosel == 1: 
  649.             face.sel = 1
  650.     if thereAreMats == 1:
  651.         if reassignMats == 0 or doodTopMat == 0:
  652.             face.materialIndex = currmat
  653.         else:
  654.             face.materialIndex = doodTopMat-1
  655.     doodadMesh.faces.append(face)
  656.     face = Face()
  657.     face.v.extend([topVertArray[5],topVertArray[6],topVertArray[7],topVertArray[8]])
  658.     if tosel == 1: 
  659.             face.sel = 1
  660.     if thereAreMats == 1:
  661.         if reassignMats == 0 or doodTopMat == 0:
  662.             face.materialIndex = currmat
  663.         else:
  664.             face.materialIndex = doodTopMat-1
  665.     doodadMesh.faces.append(face)
  666.     face = Face()
  667.     face.v.extend([topVertArray[8],topVertArray[9],topVertArray[2],topVertArray[5]])
  668.     if tosel == 1: 
  669.             face.sel = 1
  670.     if thereAreMats == 1:
  671.         if reassignMats == 0 or doodTopMat == 0:
  672.             face.materialIndex = currmat
  673.         else:
  674.             face.materialIndex = doodTopMat-1
  675.     doodadMesh.faces.append(face)
  676.     
  677. #The "S" or "Z" Shapes
  678. def SShape(facel, Xsize, Ysize, height):
  679.     #globaling junk
  680.     global face
  681.     global tosel
  682.     global doodadMesh
  683.     
  684.     face = Face()
  685.     face = facel
  686.     
  687.     findDoodadCenter(Xsize, Ysize)
  688.     
  689.     rcony1 = randnum(0.1,0.49)
  690.     rcony2 = randnum(0.51,0.9)
  691.     rconx1 = randnum(0.1,0.49)
  692.     rconx2 = randnum(0.51,0.9)
  693.     
  694.     vertArray = []
  695.     
  696.     #place S shape
  697.     vertArray.append(makePoint(0,0))
  698.     vertArray.append(makePoint(0,rcony1))
  699.     vertArray.append(makePoint(rconx1,rcony1))
  700.     vertArray.append(makePoint(rconx1,rcony2))
  701.     vertArray.append(makePoint(rconx1,1))
  702.     vertArray.append(makePoint(rconx2,1))
  703.     vertArray.append(makePoint(1,1))
  704.     vertArray.append(makePoint(1,rcony2))
  705.     vertArray.append(makePoint(rconx2,rcony2))
  706.     vertArray.append(makePoint(rconx2,rcony1))
  707.     vertArray.append(makePoint(rconx2,0))
  708.     vertArray.append(makePoint(rconx1,0))
  709.     topVertArray = extrudedoodad(vertArray,height)
  710.     
  711.     #fills bottom with faceness
  712.     face = Face()
  713.     face.v.extend([vertArray[0],vertArray[1],vertArray[2],vertArray[11]])
  714.     face.v.reverse()
  715.     if thereAreMats == 1:
  716.         if reassignMats == 0 or doodTopMat == 0:
  717.             face.materialIndex = currmat
  718.         else:
  719.             face.materialIndex = doodTopMat-1
  720.     doodadMesh.faces.append(face)
  721.     face = Face()
  722.     face.v.extend([vertArray[2],vertArray[9],vertArray[10],vertArray[11]])
  723.     face.v.reverse()
  724.     if thereAreMats == 1:
  725.         if reassignMats == 0 or doodTopMat == 0:
  726.             face.materialIndex = currmat
  727.         else:
  728.             face.materialIndex = doodTopMat-1
  729.     doodadMesh.faces.append(face)
  730.     face = Face()
  731.     face.v.extend([vertArray[2],vertArray[3],vertArray[8],vertArray[9]])
  732.     face.v.reverse()
  733.     if thereAreMats == 1:
  734.         if reassignMats == 0 or doodTopMat == 0:
  735.             face.materialIndex = currmat
  736.         else:
  737.             face.materialIndex = doodTopMat-1
  738.     doodadMesh.faces.append(face)
  739.     face = Face()
  740.     face.v.extend([vertArray[3],vertArray[4],vertArray[5],vertArray[8]])
  741.     face.v.reverse()
  742.     if thereAreMats == 1:
  743.         if reassignMats == 0 or doodTopMat == 0:
  744.             face.materialIndex = currmat
  745.         else:
  746.             face.materialIndex = doodTopMat-1
  747.     doodadMesh.faces.append(face)
  748.     face = Face()
  749.     face.v.extend([vertArray[5],vertArray[6],vertArray[7],vertArray[8]])
  750.     face.v.reverse()
  751.     if thereAreMats == 1:
  752.         if reassignMats == 0 or doodTopMat == 0:
  753.             face.materialIndex = currmat
  754.         else:
  755.             face.materialIndex = doodTopMat-1
  756.     doodadMesh.faces.append(face)
  757.     
  758.     #fills top with faceness
  759.     face = Face()
  760.     face.v.extend([topVertArray[0],topVertArray[1],topVertArray[2],topVertArray[11]])
  761.     if tosel == 1: 
  762.             face.sel = 1
  763.     if thereAreMats == 1:
  764.         if reassignMats == 0 or doodTopMat == 0:
  765.             face.materialIndex = currmat
  766.         else:
  767.             face.materialIndex = doodTopMat-1
  768.     doodadMesh.faces.append(face)
  769.     face = Face()
  770.     face.v.extend([topVertArray[2],topVertArray[9],topVertArray[10],topVertArray[11]])
  771.     if tosel == 1: 
  772.             face.sel = 1
  773.     if thereAreMats == 1:
  774.         if reassignMats == 0 or doodTopMat == 0:
  775.             face.materialIndex = currmat
  776.         else:
  777.             face.materialIndex = doodTopMat-1
  778.     doodadMesh.faces.append(face)
  779.     face = Face()
  780.     face.v.extend([topVertArray[2],topVertArray[3],topVertArray[8],topVertArray[9]])
  781.     if tosel == 1: 
  782.             face.sel = 1
  783.     if thereAreMats == 1:
  784.         if reassignMats == 0 or doodTopMat == 0:
  785.             face.materialIndex = currmat
  786.         else:
  787.             face.materialIndex = doodTopMat-1
  788.     doodadMesh.faces.append(face)
  789.     face = Face()
  790.     face.v.extend([topVertArray[3],topVertArray[4],topVertArray[5],topVertArray[8]])
  791.     if tosel == 1: 
  792.             face.sel = 1
  793.     if thereAreMats == 1:
  794.         if reassignMats == 0 or doodTopMat == 0:
  795.             face.materialIndex = currmat
  796.         else:
  797.             face.materialIndex = doodTopMat-1
  798.     doodadMesh.faces.append(face)
  799.     face = Face()
  800.     face.v.extend([topVertArray[5],topVertArray[6],topVertArray[7],topVertArray[8]])
  801.     if tosel == 1: 
  802.             face.sel = 1
  803.     if thereAreMats == 1:
  804.         if reassignMats == 0 or doodTopMat == 0:
  805.             face.materialIndex = currmat
  806.         else:
  807.             face.materialIndex = doodTopMat-1
  808.     doodadMesh.faces.append(face)
  809.     
  810. def ZShape(facel, Xsize, Ysize, height):
  811.     #globaling junk
  812.     global face
  813.     global tosel
  814.     global doodadMesh
  815.     
  816.     face = Face()
  817.     face = facel
  818.     
  819.     findDoodadCenter(Xsize, Ysize)
  820.     
  821.     rcony1 = randnum(0.1,0.49)
  822.     rcony2 = randnum(0.51,0.9)
  823.     rconx1 = randnum(0.1,0.49)
  824.     rconx2 = randnum(0.51,0.9)
  825.     
  826.     vertArray = []
  827.     
  828.     #place Z shape
  829.     vertArray.append(makePoint(0,0))
  830.     vertArray.append(makePoint(0,rcony1))
  831.     vertArray.append(makePoint(0,rcony2))
  832.     vertArray.append(makePoint(rconx1,rcony2))
  833.     vertArray.append(makePoint(rconx2,rcony2))
  834.     vertArray.append(makePoint(rconx2,1))
  835.     vertArray.append(makePoint(1,1))
  836.     vertArray.append(makePoint(1,rcony2))
  837.     vertArray.append(makePoint(1,rcony1))
  838.     vertArray.append(makePoint(rconx2,rcony1))
  839.     vertArray.append(makePoint(rconx1,rcony1))
  840.     vertArray.append(makePoint(rconx1,0))
  841.     topVertArray = extrudedoodad(vertArray,height)
  842.     
  843.     #fills bottom with faceness
  844.     face = Face()
  845.     face.v.extend([vertArray[0],vertArray[1],vertArray[10],vertArray[11]])
  846.     face.v.reverse()
  847.     if thereAreMats == 1:
  848.         if reassignMats == 0 or doodTopMat == 0:
  849.             face.materialIndex = currmat
  850.         else:
  851.             face.materialIndex = doodTopMat-1
  852.     doodadMesh.faces.append(face)
  853.     face = Face()
  854.     face.v.extend([vertArray[1],vertArray[2],vertArray[3],vertArray[10]])
  855.     face.v.reverse()
  856.     if thereAreMats == 1:
  857.         if reassignMats == 0 or doodTopMat == 0:
  858.             face.materialIndex = currmat
  859.         else:
  860.             face.materialIndex = doodTopMat-1
  861.     doodadMesh.faces.append(face)
  862.     face = Face()
  863.     face.v.extend([vertArray[3],vertArray[4],vertArray[9],vertArray[10]])
  864.     face.v.reverse()
  865.     if thereAreMats == 1:
  866.         if reassignMats == 0 or doodTopMat == 0:
  867.             face.materialIndex = currmat
  868.         else:
  869.             face.materialIndex = doodTopMat-1
  870.     doodadMesh.faces.append(face)
  871.     face = Face()
  872.     face.v.extend([vertArray[4],vertArray[7],vertArray[8],vertArray[9]])
  873.     face.v.reverse()
  874.     if thereAreMats == 1:
  875.         if reassignMats == 0 or doodTopMat == 0:
  876.             face.materialIndex = currmat
  877.         else:
  878.             face.materialIndex = doodTopMat-1
  879.     doodadMesh.faces.append(face)
  880.     face = Face()
  881.     face.v.extend([vertArray[4],vertArray[5],vertArray[6],vertArray[7]])
  882.     face.v.reverse()
  883.     if thereAreMats == 1:
  884.         if reassignMats == 0 or doodTopMat == 0:
  885.             face.materialIndex = currmat
  886.         else:
  887.             face.materialIndex = doodTopMat-1
  888.     doodadMesh.faces.append(face)
  889.     
  890.     #fills top with faceness
  891.     face = Face()
  892.     face.v.extend([topVertArray[0],topVertArray[1],topVertArray[10],topVertArray[11]])
  893.     if tosel == 1: 
  894.             face.sel = 1
  895.     if thereAreMats == 1:
  896.         if reassignMats == 0 or doodTopMat == 0:
  897.             face.materialIndex = currmat
  898.         else:
  899.             face.materialIndex = doodTopMat-1
  900.     doodadMesh.faces.append(face)
  901.     face = Face()
  902.     face.v.extend([topVertArray[1],topVertArray[2],topVertArray[3],topVertArray[10]])
  903.     if tosel == 1: 
  904.             face.sel = 1
  905.     if thereAreMats == 1:
  906.         if reassignMats == 0 or doodTopMat == 0:
  907.             face.materialIndex = currmat
  908.         else:
  909.             face.materialIndex = doodTopMat-1
  910.     doodadMesh.faces.append(face)
  911.     face = Face()
  912.     face.v.extend([topVertArray[3],topVertArray[4],topVertArray[9],topVertArray[10]])
  913.     if tosel == 1: 
  914.             face.sel = 1
  915.     if thereAreMats == 1:
  916.         if reassignMats == 0 or doodTopMat == 0:
  917.             face.materialIndex = currmat
  918.         else:
  919.             face.materialIndex = doodTopMat-1
  920.     doodadMesh.faces.append(face)
  921.     face = Face()
  922.     face.v.extend([topVertArray[4],topVertArray[7],topVertArray[8],topVertArray[9]])
  923.     if tosel == 1: 
  924.             face.sel = 1
  925.     if thereAreMats == 1:
  926.         if reassignMats == 0 or doodTopMat == 0:
  927.             face.materialIndex = currmat
  928.         else:
  929.             face.materialIndex = doodTopMat-1
  930.     doodadMesh.faces.append(face)
  931.     face = Face()
  932.     face.v.extend([topVertArray[4],topVertArray[5],topVertArray[6],topVertArray[7]])
  933.     if tosel == 1: 
  934.             face.sel = 1
  935.     if thereAreMats == 1:
  936.         if reassignMats == 0 or doodTopMat == 0:
  937.             face.materialIndex = currmat
  938.         else:
  939.             face.materialIndex = doodTopMat-1
  940.     doodadMesh.faces.append(face)
  941.     
  942.